package collection.stream;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Random;
import java.util.function.Predicate;

public class StreamApiDemo {
    public static void main(String[] args) {
        Random cd = new Random();
        List<Integer> list = new ArrayList<>();
        for (int i = 0;i<10;i++){
            list.add(cd.nextInt(100));
        }
        System.out.println(list);

        Optional<Integer>  value = list.stream().min((e1,e2)->e1-e2);
        System.out.println(value.get());
        value= list.stream().max((e1,e2)->e1-e2);
        System.out.println(value.get());

        boolean anyMath = list.stream().anyMatch(e->e%2==0);
        System.out.println(anyMath);
        boolean allMath = list.stream().allMatch(e->e%2==0);
        System.out.println(allMath);
        boolean noneMath = list.stream().noneMatch(e->e%2==0);
        System.out.println(noneMath);

        int number = list.stream().reduce((e1, e2)->e1+e2).get();
        System.out.println(number);



    }
}
